function randomArray(count = 10) {
    const arr = []
    const max = count + 1
    for (let i = 1;i < max;i++) {
        arr.push(i)
    }
    for (let i = 0;i < arr.length;i++) {
        const random_idx = parseInt(Math.random() * count)
        ;[arr[i], arr[random_idx]] = [arr[random_idx], arr[i]]
    }
    return arr
}

async function sleep(time = 0) {
    return await new Promise((resolve, reject) => {
        if (window.requestAnimationFrame) {
            window.requestAnimationFrame(resolve)
        } else if (window.webkitRequestAnimationFrame) {
            window.webkitRequestAnimationFrame(resolve)
        } else {
            setTimeout(resolve, time)
        }
    })
}

export default {
    randomArray,
    sleep
}